/* 光标样式 */
.streaming .cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background-color: var(--primary-color, #1b2efa);
  margin-left: 1px;
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  from, to {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* 消息气泡基础样式 */
.message-bubble {
  position: relative;
  margin-bottom: 16px;
  padding: 16px;
  border-radius: 12px;
  max-width: 85%;
  word-break: break-word;
  line-height: 1.6;
  animation-duration: 0.3s;
  animation-fill-mode: both;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
}

/* 用户消息 */
.message-bubble.user {
  align-self: flex-end;
  background-color: var(--user-msg-bg, rgba(27, 46, 250, 0.08));
  border: 1px solid var(--user-msg-border, rgba(27, 46, 250, 0.2));
  color: var(--text-color, #0f172a);
  animation-name: fadeInRight;
}

@media (prefers-color-scheme: dark) {
  .message-bubble.user {
    background-color: var(--user-msg-bg-dark, rgba(27, 46, 250, 0.15));
    border: 1px solid var(--user-msg-border-dark, rgba(27, 46, 250, 0.3));
    color: var(--text-color-dark, #f1f5f9);
  }
}

/* 机器人消息 */
.message-bubble.bot {
  align-self: flex-start;
  background-color: var(--bot-msg-bg, transparent);
  border: 1px solid var(--border-color, #e2e8f0);
  color: var(--text-color, #0f172a);
  animation-name: fadeInLeft;
}

@media (prefers-color-scheme: dark) {
  .message-bubble.bot {
    border: 1px solid var(--border-color-dark, #334155);
    color: var(--text-color-dark, #f1f5f9);
  }
}

/* 消息内容 */
.message-content {
  width: 100%;
}

/* 消息时间戳 */
.message-timestamp {
  font-size: 0.75rem;
  color: var(--text-secondary, #64748b);
  margin-top: 8px;
  align-self: flex-end;
}

@media (prefers-color-scheme: dark) {
  .message-timestamp {
    color: var(--text-secondary-dark, #94a3b8);
  }
}

/* 思考状态 */
.message-bubble.thinking {
  background-color: var(--bot-msg-bg, transparent);
  border: 1px solid var(--border-color, #e2e8f0);
  align-self: flex-start;
  padding: 12px 16px;
}

@media (prefers-color-scheme: dark) {
  .message-bubble.thinking {
    border: 1px solid var(--border-color-dark, #334155);
  }
}

/* 思考动画 */
.thinking-animation {
  display: flex;
  gap: 4px;
  align-items: center;
}

.thinking-dot {
  width: 8px;
  height: 8px;
  background-color: var(--primary-color, #1b2efa);
  border-radius: 50%;
  opacity: 0.6;
  animation: bounce 1.4s infinite ease-in-out both;
}

.thinking-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.thinking-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* 流式消息特殊动画效果 */
.message-bubble.streaming {
  border-color: var(--primary-color);
}

.message-bubble.streaming::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--primary-color), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* 思考状态样式 */
.thinking-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  min-width: 60px;
}

.thinking-content .dot {
  width: 8px;
  height: 8px;
  margin: 0 2px;
  background-color: var(--primary-color);
  border-radius: 50%;
  display: inline-block;
  animation: pulse 1.2s infinite;
}

.thinking-content .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-content .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes pulse {
  0%, 60%, 100% {
    transform: scale(1);
    opacity: 0.4;
  }
  30% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* 移动端优化 - 使用更明确的选择器 */
@media only screen and (max-width: 640px) {
  .message-bubble {
    padding: var(--spacing-2);
    margin-bottom: var(--spacing-3);
    max-width: 85%;
    border-radius: 14px;
  }
  
  .message-bubble.user {
    margin-left: var(--spacing-4);
  }
  
  .message-bubble.bot {
    margin-right: var(--spacing-4);
  }
  
  .thinking-text {
    font-size: 14px;
  }
}

/* 手机设备强制样式 */
@media only screen and (max-device-width: 480px),
       only screen and (max-width: 480px) {
  .message-bubble {
    max-width: 88%;
    padding: 10px 12px;
    margin-bottom: 10px;
    border-radius: 12px;
  }
  
  .message-bubble.user {
    margin-left: 10px;
  }
  
  .message-bubble.bot {
    margin-right: 10px;
  }
}

/* 代码块样式 */
.message-bubble pre {
  background-color: var(--code-bg, #f1f5f9);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin: 8px 0;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  .message-bubble pre {
    background-color: var(--code-bg-dark, #0f172a);
  }
}

/* 动画定义 */
@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 移动设备适配 */
@media (max-width: 768px) {
  .message-bubble {
    padding: 12px;
    max-width: 90%;
  }
}

/* iPhone特殊适配 */
@media only screen and (device-width: 428px) and (device-height: 926px),
       only screen and (device-width: 390px) and (device-height: 844px),
       only screen and (device-width: 393px) and (device-height: 852px) {
  .message-bubble {
    max-width: 80%;
  }
} 